package com.example.tests;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import java.util.Random;

import org.testng.annotations.Test;

import com.example.utils.SortedListOf;

public class GroupRemovalTests extends TestBase{

	@Test
	public void deleteRandomGroup() {	
	    // save old state
		SortedListOf<GroupData> oldList = app.getGroupHelper().getGroups();

		// define test data
	    Random rnd = new Random();
		int groupIndex = rnd.nextInt(oldList.size()-1);    
	    
	    // actions
		app.getGroupHelper().removeGroup(groupIndex);
		
		// save new state
		SortedListOf<GroupData> newList = app.getGroupHelper().getGroups();
		
		// compare states
		assertThat(newList, equalTo(oldList.without(groupIndex)));
	}
}
